<%@include file="../viewPartials/header.jsp" %>
<c:url value="Home" var="homeUrl" />


<h1>Edit folder</h1>
<c:choose>
    <c:when test="${param.success == 'true'}">
        Folder saved! <a href="${homeUrl}">Back</a>
    </c:when>
    <c:when test="${folder == null}">
        Folder not found <a href="${homeUrl}">Back</a>
    </c:when>
    <c:when test="${folder != null}">
        
        <c:if test="${formErrors.size() > 0}">
            <div class="formErrors">
                <c:forEach var="error" items="${formErrors}">
                    ${fn:escapeXml(error)}<br>
                </c:forEach>
            </div>
        </c:if>
        
        <form method="post" action="">
            <table class="tblForm">
                <tr>
                    <td width="60"><label for="name">Name</label></td>
                    <td><input type="text" name="name" id="name" value="${fn:escapeXml(folder.name)}"></td>
                </tr>
                <tr>
                    <td><label>Parent</label></td>
                    <td>
                        <input name="parentId" 
                                id="txtParentId"
                                value="${folder.parent.id}"
                                data-foldername="${fn:escapeXml(folder.parent.name)}">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="submit" name="submit" value="Save"></td>
                </tr>
            </table>
            <a href="${homeUrl}">Back</a>
        </form> 
    </c:when>
</c:choose>

<%@include file="../viewPartials/footer.jsp" %>